<template>
  <div>
    <h1>老师登录</h1>
    <form action="" @submit.prevent="login" v-model="form">
      <p>老师姓名: <input type="text" v-model="form.username"></p>
      <p>密 码: <input type="password" v-model="form.password"></p>
      <button type="submit">登录</button>
    </form>
  </div>
</template>

<script>
export default {
  data() {
    return {
      form: {}
    }
  },
  methods: {
    login() {
      this.axios.post('teacherLogin/', this.form)
        .then(res => {
          if (res.data.code == 200) {
            localStorage.setItem('tid', res.data.tid)
            localStorage.setItem('tname', res.data.tname)
          }
          this.$router.push({'path': '/stu'})
        })
    }
  },
  mounted() {
  }
}
</script>

<style scoped>

</style>
